home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: quick decision: is n a power of 2?
- Date: Sun, 04 Feb 96 13:13:04 GMT
- Organization: none
- Message-ID: <823439584snz@genesis.demon.co.uk>
- References: <Pine.OSF.3.91.960119114608.18779E-100000@io.UWinnipeg.ca> <TANMOY.96Jan21104404@qcd.lanl.gov> <4e6rs0$dvl@ns.RezoNet.NET> <9601251245.AA12220@dxmint.cern.ch> <822791542snz@genesis.demon.co.uk> <4er59u$1tc@nntp5.u.washington.edu>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4er59u$1tc@nntp5.u.washington.edu>
- gah@u.washington.edu "G. Herrmannsfeldt" writes:
-
- >Are there any ones-complement machines (I think CDC used to make them),
- >with C compilers that generate the two's complement for -u on an unsigned int?
-
- The bit manipulations required to perform unsigned arithmetic are different
- for those required to perform 1's complement arithmetic. The compiler would
- have to generate instructions to perform the correct bit manipulations for
- -u and these would have to be a different sequence to those generated for -s
- (on a signed int), unless the compiler simulates a 2's complement environment
- for the C program.
-
- The nice thing about 2's complement is that in most cases the bit
- manipulations required are the same as for unsigned arithmetic. The
- difference is how the result is interpreted (for example how condition
- codes are tested).
-
- >I suppose it makes a little sense, but are there really any?
- >
- >And, for that matter, what about BCD machines? Maybe they are rare, too.
-
- That is a different case because C doesn't support BCD as a representation
- model. The compiler for such a system wuould therefore have to jump through
- significant hoops to simulate a 'pure' binary environment for the C
- program to run in.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-